a = input()
stack = []
ans = True
for i in range(len(a)):
    if a[i] == '(':
        stack.append(a[i])
    elif a[i] == ')':
        if stack and stack[-1] == '(':
            stack.pop()
        else:
            ans = False
            break
    if a[i] == '{':
        stack.append(a[i])
    elif a[i] == '}':
        if stack and stack[-1] == '{':
            stack.pop()
        else:
            ans = False
            break

    if a[i] == '[':
        stack.append(a[i])
    elif a[i] == ']':
        if stack and stack[-1] == '[':
            stack.pop()
        else:
            ans = False
            break

    if a[i] == '<':
        stack.append(a[i])
    elif a[i] == '>':
        if stack and stack[-1] == '<':
            stack.pop()
        else:
            ans = False
            break
if not stack and ans:
    print('YES')
else:
    print('NO')